#!/usr/bin/ruby -Ku
# -*- coding: utf-8 -*-
require 'test/unit'
require 'm3g'

class Test_Light < Test::Unit::TestCase
  def setup
  end

  def teadown
  end

  def test_defualt_variables
    lgh = M3G::Light.new

    assert_equal M3G::Light::DIRECTIONAL, lgh.mode
    assert_equal 0x00ffffff, lgh.color
    assert_equal 1,          lgh.attenuation.constant
    assert_equal 0,          lgh.attenuation.linear
    assert_equal 0,          lgh.attenuation.quadratic
    assert_equal 45,         lgh.spot.angle
    assert_equal 0,          lgh.spot.exponent
  end

  def test_set_variables
    lgh = M3G::Light.new 

    lgh.attenuation   = [1,2,3]
    lgh.color         = 0x12345678
    lgh.intensity     = 100
    lgh.mode          = M3G::Light::OMNI
    lgh.spot.angle    = 90
    lgh.spot.exponent = 2

    assert_equal M3G::Light::OMNI, lgh.mode
    assert_equal 0x00345678, lgh.color
    assert_equal 1,          lgh.attenuation.constant
    assert_equal 2,          lgh.attenuation.linear
    assert_equal 3,          lgh.attenuation.quadratic
    assert_equal 90,         lgh.spot.angle
    assert_equal 2,          lgh.spot.exponent
  end

  def test_duplicate
    lgh1 = M3G::Light.new

    lgh1.attenuation   = [1,2,3]
    lgh1.color         = 0x12345678
    lgh1.intensity     = 100
    lgh1.mode          = M3G::Light::OMNI
    lgh1.spot.angle    = 90
    lgh1.spot.exponent = 2

    lgh2 = lgh1.duplicate

    assert_equal M3G::Light::OMNI, lgh2.mode
    assert_equal 0x00345678, lgh2.color
    assert_equal 1,          lgh2.attenuation.constant
    assert_equal 2,          lgh2.attenuation.linear
    assert_equal 3,          lgh2.attenuation.quadratic
    assert_equal 90,         lgh2.spot.angle
    assert_equal 2,          lgh2.spot.exponent

  end
end
